package cn.javaeye.lonlysky.lforum.service;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.hibernate.SimpleHibernateTemplate;

import cn.javaeye.lonlysky.lforum.entity.web.ParentType;


@Service
@Transactional
public class ParentTypeManager {

	private SimpleHibernateTemplate<ParentType, Integer> parentTypeDAO;


	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		parentTypeDAO = new SimpleHibernateTemplate<ParentType, Integer>(sessionFactory, ParentType.class);
	}
	/**
	 * 
	 * @return
	 */
	public List<ParentType> findAll() {
		return parentTypeDAO.findAll();
	}
	public List<ParentType> findByFid(Integer id) {
		return parentTypeDAO.findByProperty("fartherType.id", id);
	}
	public void createFartherType(ParentType parentType) {
		parentTypeDAO.save(parentType);
	}
	public void remove(Integer id) {
		
		parentTypeDAO.delete(id);
	}
	public ParentType get(Integer id) {
		return parentTypeDAO.get(id);
	}

}
